package com.lnt.spring.bean.postprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;

/**
 * @title :
 * @createDate : 2021-11-16 17:42
 * @creater : LuNanTing
 * @className : SpringBeanInstantiationPostProcessorTest
 */

/**
 * Bean创建的声明周期
 * 启动ApplicationContext
 * 创建BeanFactory
 * 初始化BeanFactory
 * 执行BeanFactory后置处理器
 * 进行扫描
 * 生成BeanDefinition
 * 合并BeanDefinition
 * 加载类
 * 实例化前 InstantiationAwareBeanPostProcessor接口提供了自定义实例化
 * 推断构造器
 * 实例化
 * BeanDefinition后置构造器
 * 实例化后
 * 填充属性(Spring 自带的依赖注入 InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation())
 * 填充属性后
 * 执行Aware
 * 初始化前
 * 初始化
 * 初始化后
 */
//@Component
public class SpringBeanInstantiationPostProcessorTest extends SpringBeanPostProcessorTest implements InstantiationAwareBeanPostProcessor {

    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        System.out.println("beanCLass:" + beanClass);
        System.out.println("bean对象{" + beanName + "}实例化前");
        return beanClass;
    }
}
